package practicedemo42;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        //1.接受数据
        Scanner sc = new Scanner(System.in);
        String id = "";
        while (true) {
            System.out.println("请输入身份证号码");
            id = sc.next();
            if (id.length() != 18) {
                System.out.println("错误的身份证号码");
            } else {
                break;
            }
        }
        //根据位数获得相应的数据：
        String birth = id.substring(6,10)+"年"+id.substring(10,12)+"月"+ id.substring(12,14)+"日";
        String sex = id.substring(16,17);
        if (sex.equals("1")){
            sex = "男";
        } else {
            sex = "女";
        }
        System.out.println("birth:"+'\t'+birth+'\n'+"sex:"+'\t'+sex);
    }

}
